package com.ycg.biquge.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.ycg.biquge.common.Result;
import com.ycg.biquge.pojo.User;
import com.ycg.biquge.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @author YCG
 * @date 2024-04-29 21:04
 * @description 用户控制器
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 登录
     * @return token
     */
    @PostMapping("/login")
    public Result<String> login(@RequestBody @Validated User user) {
        return userService.login(user);
    }

    /**
     * 登出
     * @return status
     */
    @DeleteMapping("/logout")
    public Result<String> logout() {
        return userService.logout();
    }

    /**
     * 注册
     * @return status
     */
    @PostMapping("/register")
    public Result<String> register(@RequestBody @Validated User user) {
        return userService.register(user);
    }
}
